//
//  ViewController.m
//  SchedBlock
//
//  Created by GC_tandy on 2019/1/21.
//  Copyright © 2019年 GC_tandy. All rights reserved.
//

#import "ViewController.h"
#import "NSObject+SchedBlock.h"

@interface ViewController ()<SchedBlock>

@property (nonatomic,strong) NSTimer *timer_01;

@property (nonatomic,strong) NSTimer *timer_02;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
//    [self testAction_01];
//    [self testAction_02];
}

- (IBAction)btnAction:(id)sender {
    NSDate *startDate = [NSDate date];
    __block NSDate *lastDate = nil;
    [self schedNewTaskBlock:^{
        NSDate *logDate = [NSDate date];
        NSLog(@"schedNewTaskBlock logNum ->%f 1",[logDate timeIntervalSinceDate:startDate]);
        lastDate = logDate;
    } refreshDelay:0.5];
    
    [self schedNewTaskBlock:^{
        NSDate *logDate = [NSDate date];
        NSLog(@"schedNewTaskBlock logNum ->%f 2",[logDate timeIntervalSinceDate:startDate]);
        lastDate = logDate;
    } refreshDelay:0.7];
    
}


- (void)testAction_01{
    NSDate *startDate = [NSDate date];
    __block NSDate *lastDate = nil;
    NSTimer *timer = [NSTimer timerWithTimeInterval:0.001 repeats:YES block:^(NSTimer * _Nonnull timer) {
        [self schedNewTaskBlock:^{
            NSDate *logDate = [NSDate date];
            NSLog(@"schedNewTaskBlock logNum ->%f spaceForLastDate ->%f",[logDate timeIntervalSinceDate:startDate],[logDate timeIntervalSinceDate:lastDate]);
            lastDate = logDate;
        }];
    }];
    self.timer_01 = timer;
    [[NSRunLoop currentRunLoop]addTimer:timer forMode:NSRunLoopCommonModes];
}

- (void)testAction_02{
    NSDate *startDate = [NSDate date];
    __block NSDate *lastDate = nil;
    NSTimer *timer = [NSTimer timerWithTimeInterval:0.001 repeats:YES block:^(NSTimer * _Nonnull timer) {
        [self schedNewTaskBlock:^{
            NSDate *logDate = [NSDate date];
            NSLog(@"schedNewTaskBlock logNum ->%f spaceForLastDate ->%f",[logDate timeIntervalSinceDate:startDate],[logDate timeIntervalSinceDate:lastDate]);
            lastDate = logDate;
        } refreshDelay:0.7];
    }];
    self.timer_02 = timer;
    [[NSRunLoop currentRunLoop]addTimer:timer forMode:NSRunLoopCommonModes];
}


@end
